/*************************************************************************
	> File Name: p1135.cpp
	> Author: zhangxu 
	> Mail: walrus1983@126.com
	> Created Time: 四  8/29 14:26:39 2024
 ************************************************************************/

#include <cstdio>
#include <cstdlib>
using namespace std;

#define MAX_N 200
int to[MAX_N + 5];
int dis[MAX_N + 5] = {0};

void dfs(int k, int a, int n) {
	if(dis[a] <= k) return ;
	dis[a] = k;
	if(a + to[a] <= n) dfs(k + 1, a + to[a], n);
	if(a - to[a] >= 1) dfs(k + 1, a - to[a], n);
	return ;
}

int main() {
	int n, a, b;
	scanf("%d%d%d", &n, &a, &b);
	for(int i = 1; i <=n; i++) {
		scanf("%d", to + i);
	}
	for(int i = 1; i <= n; i++) {
		dis[i] = n + 1;
	}
	// 从a到达每个点的最短距离
	dfs(0, a, n);
	printf("%d\n", dis[b] > n ? -1 : dis[b]);
	return 0;
}